<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main</title>
<jsp:include page="../head.jsp" />
<script type="text/javascript">

	function save(){
		var sessionOldPasswordVal="${sessionScope.sessionUser.expressPwd}";
		var oldPasswordVal=$("#oldPassword").val();
		var newPasswordVal=$("#newPassword").val();
		var confirmPasswordVal=$("#confirmPassword").val();
	    if (oldPasswordVal== '') {
	        j_tip("请输入旧密码。", 'error');
	        return;
	    }else if (newPasswordVal== '') {
	        j_tip("请输入新密码。", 'error');
	        return;
	    }else if (confirmPasswordVal== '') {
	        j_tip("请确认密码。", 'error');
	        return;
	    }else if (oldPasswordVal!= sessionOldPasswordVal) {
	        j_tip("旧密码验证未通过。", 'error');
	        return;
	    }else if (confirmPasswordVal!=newPasswordVal) {
	        j_tip("两次输入的新密码必须相同。", 'error');
	        return;
	    }else{
	    	$.ajax({
					url			:"<%=path%>/user/userAjax_changePassword_msgAction.action",
					type 		: "POST",
					dataType 	: "json",
					data		: {
						"userId" : "${sessionScope.sessionUser.userId}",
						"password" : confirmPasswordVal
					},
					success 	: function(data) {
						parent.j_tip(data,'success');
						parent.closeSearchBox();
					},
					error		:function(){
						j_tip("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
					}
			});
	    }
	}
	
	function turnBack(){
		parent.closeSearchBox();
	}

</script>

</head>
<body>
<form action="<%=path%>/position/position_modify_listAction.action" method="post" id="saveForm">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr bgcolor="#FFFFFF">
    <td colspan="2" height="16"><span></span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="30%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>原密码：</td>
    <td width="70%" align="left" bgcolor="#FFFFFF">
          <input maxlength="25" type="password" name="oldPassword" id="oldPassword" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="30%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>新密码：</td>
    <td width="70%" align="left" bgcolor="#FFFFFF">
    	<input maxlength="25" type="password" name="newPassword" id="newPassword"/>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="30%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>确认密码：</td>
    <td width="70%" align="left" bgcolor="#FFFFFF">
          <input maxlength="25" type="password" name="confirmPassword" id="confirmPassword" />
    </td>
  </tr>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="4" align="center">
		<input type='button' class="btn btn-primary" id="btnSave" onclick="save();" value='保存' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>
</form>

</body>
</html>
